package com.example.interceptors;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.example.annotation.LoginRequired;

/**
 * @author jiangwz
 * @create 2019/7/2.
 */
@Component
public class SsoAuthInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("preHandle");
        HandlerMethod method = (HandlerMethod)handler;
        LoginRequired methodAnnotation = method.getMethodAnnotation(LoginRequired.class);
        if (methodAnnotation == null) {
            return true;
        }

        // 有登录注解，则判断用户有没有登录


        return true;
    }
}
